package com.tbit.uqbike.client.util.tbit;

import cn.hutool.http.HttpRequest;
import lombok.extern.slf4j.Slf4j;

import java.io.File;
import java.util.HashMap;
import java.util.Map;

/**
 * 华慧拍照还车校验工具类
 *
 * @Author: chen
 * @Description:
 * @Date: 创建于 15:35 2023/8/15
 */
@Slf4j
public class HuaHuiHttpUtils {

    private static String URL = "https://www.huahuizhineng.com:600/recognition/parking";

    public static String recognition(String apiSecret, Integer photoReturnAngle, Integer photoReturnDistance, String bicycleSignColor,
                                     File file) {
        try {
            Long startTime = System.currentTimeMillis();
            Map<String, Object> map = new HashMap<>();
            map.put("photoReturnAngle", photoReturnAngle);
            map.put("photoReturnDistance", photoReturnDistance);
            map.put("bicycleSignColor", bicycleSignColor);
            map.put("file", file);
            String result = HttpRequest.post(URL)
                    .header("apiSecret", apiSecret).form(map).timeout(3000).execute().body();
            log.info("调用华慧拍照还车耗时{}毫秒" + (System.currentTimeMillis() - startTime));
            return result;
        } catch (Exception e) {
            log.error("调用华慧拍照校验接口异常", e);
        }
        return null;
    }

    public static void main(String[] args) {
        System.out.println(recognition("dd8ddd042a6e4d45", 20, 100, "05070204"
                , new File("C:\\Users\\Administrator\\Desktop\\1.jpg")));

    }
}
